using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace AtCareApplication
{
    class Meals
    {
        private long id;
        private string mealCode;
        private string resId;
        private string meals;
        private string amount;
        private DateTime transactionDate;

        public Meals(Meals meal)
        {
            id              = meal.id;
            mealCode        = meal.mealCode;
            resId           = meal.resId;
            meals           = meal.meals;
            amount          = meal.amount;
            transactionDate = meal.transactionDate;
        }

        public Meals(long id, string mealCode, string resId, string meals, string amount, DateTime transactionDate)
        {
            this.id                 = id;
            this.mealCode           = mealCode;
            this.resId              = resId;
            this.meals              = meals;
            this.amount             = amount;
            this.transactionDate    = transactionDate;
        }

        public DateTime getTransactionDate()
        {
            return transactionDate;
        }

        public void setTransactionDate(int year, int month, int day, int hour, int minute, int second)
        {
           transactionDate = new DateTime(year, month, day, hour, minute, second); // this needs to be updated from the database or set system clock
        }

        public long getId()
        {
            return id;
        }

        public void setId(long id)
        {
            this.id = id;
        }

        public string getMealCode()
        {
            return mealCode;
        }

        public void setMealCode(string mealCode)
        {
            this.mealCode = mealCode;
        }

        public string getResId()
        {
            return resId;
        }

        public void setResId(string resId)
        {
            this.resId = resId;
        }

        public string getMeals()
        {
            return meals;
        }

        public void setMeals(string meals)
        {
            this.meals = meals;
        }

        public string getAmount() 
        {
            return amount;
        }

        public void setAmount(string amount)
        {
            this.amount = amount;
        }

        public string getDate()
        {
            return this.transactionDate.ToString("d");
        }

        public string getTime()
        {
            string hourToString = this.transactionDate.Hour.ToString();
            string minuteToString = this.transactionDate.Minute.ToString();
            string secondToString = this.transactionDate.Second.ToString();

            if (hourToString.Length == 1)
            {
                hourToString = "0" + hourToString;
            }
            if (minuteToString.Length == 1)
            {
                minuteToString = "0" + minuteToString;
            }
            if (secondToString.Length == 1)
            {
                secondToString = "0" + secondToString;
            }
            
            string time = hourToString + ":" + minuteToString + ":" + secondToString;
            return time;
        }
    }
}
